package thread.semaphore;

import java.util.Objects;

/**
 * 创建一个不可变对象
 *
 * @author wei.yang on 2018/8/7
 */
public class Model {

    private final int modelNum;

    Model(int modelNum) {
        this.modelNum = modelNum;
    }

    public int getModelNum() {
        return modelNum;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(modelNum);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Model) {
            return modelNum == ((Model) obj).modelNum;
        }
        return false;
    }

    @Override
    public String toString() {
        return "Model{" +
                "modelNum=" + modelNum +
                '}';
    }
}
